package edu.hubu.phoneorder.controller;

import com.alibaba.fastjson.JSON;
import edu.hubu.phoneorder.pojo.SalesAmount;
import edu.hubu.phoneorder.service.impl.SalesAmountServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author wise-wang
 * @time 2021.12.09
 * @describe Controller层，控制web页面显示的内容，定义url
 */
@Controller
public class SalesAmountController {

    @Autowired
    private SalesAmountServiceImpl salesAmountService;

    @GetMapping("/hello")
    @ResponseBody
    public String hello() {
        return "hello spring boot";
    }

    @GetMapping("/index")
    public String index() {
        return "index";
    }

    @GetMapping("/salesamount")
    @ResponseBody
    public String amount() {
        List<SalesAmount> list = salesAmountService.getList();
        return JSON.toJSONString(list);
    }
}
